#! /bin/bash

# 下载
wget https://mirrors.cnnic.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz --no-check-certificate
# 解压
tar -zxvf apache-maven-3.5.4-bin.tar.gz 
mv apache-maven-3.5.4 /usr/local/maven
# 与jenkins联合使用时，jenkins会到/usr/bin/下找mvn命令，如果没有回报错
ln -s /usr/local/maven/bin/mvn  /usr/bin/mvn　　　　
ll /usr/local/maven/
ll /usr/bin/mvn
# 配置环境变量
echo " ">>/etc/profile
echo "# Made for mvn env by lk on $(date +%F)">>/etc/profile
echo 'export MAVEN_HOME=/usr/local/maven'>>/etc/profile
echo 'export PATH=$MAVEN_HOME/bin:$PATH'>>/etc/profile
tail -4 /etc/profile
source /etc/profile
echo $PATH
# 查看mvn版本
which mvn
mvn -version

# 默认mvn从国外下载依赖，速度较慢，可以自行百度，更改为国内的镜像仓库，以提高速度！